package com.heima.wemedia.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dto.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * 自媒体素材表(WmMaterial)表控制层
 *
 * @author makejava
 * @since 2022-04-12 18:09:39
 */
@RestController
@RequestMapping("/api/v1/material")
@Api(value = "自媒体素材管理",tags = "自媒体",description = "自媒体素材管理API")
public class WmMaterialController {
    /**
     * 服务对象
     */
    @Resource
    private WmMaterialService wmMaterialService;


    /**
     * 自媒体素材上传
     * @param multipartFile
     * @return
     */
    @PostMapping(path = "/upload_picture")
    @ApiOperation("自媒体素材上传")
    public ResponseResult upload(MultipartFile multipartFile){

        return wmMaterialService.upload(multipartFile);
    }

    /**
     * 素材列表查询
     * @param dto
     * @return
     */
    @PostMapping(path = "/list")
    @ApiOperation("自媒体素材列表分页查询")
    public ResponseResult list(@RequestBody WmMaterialDto dto){
        return wmMaterialService.queryByPage(dto);
    }

}

